package com.cjm.one.model.order.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Objects;

import com.cjm.one.model.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * 订单项信息
 * @TableName order_item
 */
@TableName(value ="order_item")
@Data
public class OrderItem extends BaseEntity {


    /**
     * order_id
     */
    @TableField(value = "order_id")
    @Schema(description = "order_id")
    private Long orderId;

    /**
     * 商品sku编号
     */
    @TableField(value = "sku_id")
    @Schema(description = "商品sku编号")
    private Long skuId;
    /**
     * 使用的优惠券
     */
    @Schema(description = "使用的优惠券")
    @TableField(value = "coupon_id")
    private Long couponId;
    /**
     * 商品sku编码
     */
    @TableField(value = "sku_code")
    @Schema(description = "商品sku编号")
    private String skuCode;
    /**
     * 商品id
     */
    @TableField(value = "goods_id")
    @Schema(description = "商品id")
    private Long goodsId;

    /**
     * 商品sku名字
     */
    @TableField(value = "sku_name")
    @Schema(description = "商品sku名字")
    private String skuName;

    /**
     * 商品sku图片
     */
    @TableField(value = "thumb_img")
    @Schema(description = "商品sku图片")
    private String thumbImg;

    /**
     * 商品sku价格
     */
    @TableField(value = "sku_price")
    @Schema(description = "商品sku价格")
    private BigDecimal skuPrice;

    @TableField(value = "sale_total_price")
    @Schema(description = "总金额")
    private BigDecimal saleTotalPrice;

    @TableField(value = "discount_price")
    @Schema(description = "优惠金额")
    private BigDecimal discountPrice;

    @TableField(value = "sku_market_price")
    @Schema(description = "商品市场价格")
    private BigDecimal skuMarketPrice;
    /**
     * 商品购买的数量
     */
    @TableField(value = "sku_num")
    @Schema(description = "商品购买的数量")
    private Integer skuNum;


    @TableField(value = "revert_quantity")
    @Schema(description = "可回滚数量")
    private Integer revertQuantity;

    @TableField(value = "is_reverted")
    @Schema(description = "是否回滚")
    private Integer isReverted;

    @TableField(value = "revert_time")
    @Schema(description = "回滚时间")
    private LocalDateTime revertTime;


    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof OrderItem orderItem)) return false;
        if (!super.equals(o)) return false;
        return Objects.equals(getOrderId(), orderItem.getOrderId()) && Objects.equals(getSkuId(), orderItem.getSkuId()) && Objects.equals(getCouponId(), orderItem.getCouponId()) && Objects.equals(getSkuCode(), orderItem.getSkuCode()) && Objects.equals(getGoodsId(), orderItem.getGoodsId()) && Objects.equals(getSkuName(), orderItem.getSkuName()) && Objects.equals(getThumbImg(), orderItem.getThumbImg()) && Objects.equals(getSkuPrice(), orderItem.getSkuPrice()) && Objects.equals(getSaleTotalPrice(), orderItem.getSaleTotalPrice()) && Objects.equals(getDiscountPrice(), orderItem.getDiscountPrice()) && Objects.equals(getSkuMarketPrice(), orderItem.getSkuMarketPrice()) && Objects.equals(getSkuNum(), orderItem.getSkuNum()) && Objects.equals(getRevertQuantity(), orderItem.getRevertQuantity()) && Objects.equals(getIsReverted(), orderItem.getIsReverted()) && Objects.equals(getRevertTime(), orderItem.getRevertTime());
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), getOrderId(), getSkuId(), getCouponId(), getSkuCode(), getGoodsId(), getSkuName(), getThumbImg(), getSkuPrice(), getSaleTotalPrice(), getDiscountPrice(), getSkuMarketPrice(), getSkuNum(), getRevertQuantity(), getIsReverted(), getRevertTime());
    }

    @Override
    public String toString() {
        return "OrderItem{" +
                "orderId=" + orderId +
                ", skuId=" + skuId +
                ", couponId=" + couponId +
                ", skuCode='" + skuCode + '\'' +
                ", goodsId=" + goodsId +
                ", skuName='" + skuName + '\'' +
                ", thumbImg='" + thumbImg + '\'' +
                ", skuPrice=" + skuPrice +
                ", saleTotalPrice=" + saleTotalPrice +
                ", discountPrice=" + discountPrice +
                ", skuMarketPrice=" + skuMarketPrice +
                ", skuNum=" + skuNum +
                ", revertQuantity=" + revertQuantity +
                ", isReverted=" + isReverted +
                ", revertTime=" + revertTime +
                '}';
    }
}